package com.zmn.oms.third.dj58.service.impl;

import com.zmn.oms.common.constant.OrderLogConsts;
import com.zmn.oms.common.exception.OmsBaseException;
import com.zmn.oms.model.entity.work.OrderWorkLogChange;
import com.zmn.oms.third.dj58.DaoJia58Consts;
import com.zmn.oms.third.dj58.service.DaoJia58ReworkService;
import com.zmn.oms.zmn.business.interfaces.open.OrderChangeNotifyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author huangyifeng
 * @Description
 * @date 2020/4/13 20:56
 */
@Slf4j
@Service("daoJiaReworkNotifyService")
public class DaoJiaReworkNotifyServiceImpl implements OrderChangeNotifyService {

    @Autowired
    private DaoJia58ReworkService daoJia58ReworkService;

    @Override
    public void notifyChange(OrderWorkLogChange orderWorkLogChange) throws OmsBaseException {
        log.info("【{}】<订单状态同步> ,状态信息:[{}]。", DaoJia58Consts.REWORK_CHANNEL_NAME,orderWorkLogChange.toString());

        int logType = orderWorkLogChange.getLogType().intValue();
        switch (logType){
            // 取消
            case OrderLogConsts.ORDER_LOG_TYPE_CANCEL:
                daoJia58ReworkService.sendCancelReworkOrder(orderWorkLogChange);
                break;
            // 完成
            case OrderLogConsts.ORDER_LOG_TYPE_COMPLETE:
                daoJia58ReworkService.sendCompleteReworkOrder(orderWorkLogChange);
                break;
            default:
                return;
        }
    }
}
